package com.bytecub.simulate.device.boot;

import com.bytecub.simulate.device.common.constants.SimulateConstants;
import com.bytecub.simulate.device.common.constants.SimulateStorage;
import com.bytecub.simulate.device.instance.DeviceBoot;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Component;

import javax.annotation.PostConstruct;

/**
  * ByteCub.cn.
  * Copyright (c) 2020-2021 All Rights Reserved.
  * 
  * @author bytecub@163.com  songbin
  * @version Id: AppBoot.java, v 0.1 2021-01-07  Exp $$
  */
@Component
@Slf4j
public class AppBoot {
    @Value("${bytecub.mqtt.server.url}")
    String mqttServerUrl;
    @Value("${bytecub.mqtt.client.timeout:30}")
    int    timeout;
    @Value("${bytecub.mqtt.client.keepalive:30}")
    int    keepAlive;
    @Value("${bytecub.device.delay}")
    int delay;

    @Autowired
    DeviceBoot deviceBoot;
    @PostConstruct
    public void init(){
        SimulateStorage.setMqttServerUrl(mqttServerUrl);
        SimulateStorage.setTimeout(timeout);
        SimulateStorage.setKeepalive(keepAlive);
        SimulateConstants.DELAY_TIME = delay;
        deviceBoot.init();
    }
}
